package elitech.vietnam.myfashion.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import elitech.vietnam.myfashion.MainActivity;
import elitech.vietnam.myfashion.view.MainPageView;

public class MainPageViewFragment extends Fragment {

	private MainActivity mContext;
	private MainPageView mView = null;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.mContext = (MainActivity) getActivity();
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		mView = new MainPageView(mContext);
		return mView;
	}

	@Override
	public void onHiddenChanged(boolean hidden) {
		super.onHiddenChanged(hidden);
		if (!hidden) {
//			mContext.changeTitle(mContext.mLastTitle, false);
//			mContext.mBtnCart.setVisibility(View.GONE);
			if (mContext.mMainPageView.mPageAdapter.mBestGridView != null)
				mContext.mMainPageView.mPageAdapter.mBestGridView
						.GetProduct();
			if (mContext.mMainPageView.mPageAdapter.mCategoriesView != null)
				mContext.mMainPageView.mPageAdapter.mCategoriesView
						.GetCategories();
			if (mContext.mMainPageView.mPageAdapter.mMyStyleView != null && mContext.mUser != null )
				mContext.mMainPageView.mPageAdapter.mMyStyleView
						.RefreshMyStyle();
			if (mContext.mMyShoppingView != null && mContext.mUser != null ){
				mContext.mMyShoppingView.mFavorView.RefreshFavorite();
				mContext.mMyShoppingView.mBuyingView.GetOrder();
			}
			if (mContext.mMainPageView.mPageAdapter.mStylerView != null) {
				if (mContext.mMainPageView.mPageAdapter.mStylerView.mAllStyleView != null)
					mContext.mMainPageView.mPageAdapter.mStylerView.mAllStyleView
							.RefreshAllStyle();
				if (mContext.mMainPageView.mPageAdapter.mStylerView.mFollowStyleView != null && mContext.mUser != null )
					mContext.mMainPageView.mPageAdapter.mStylerView.mFollowStyleView
							.RefreshFollowStyle();
			}
		}
	}

	@Override
	public void onResume() {
		super.onResume();
	}
}
